package com.ychug.front.template.directive;

import com.ychug.service.system.entity.SysConfigEntity;
import com.ychug.service.system.service.ISysConfigService;
import freemarker.core.Environment;
import freemarker.template.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.List;
import java.util.Map;


@Component
public class CustomTagDirective implements TemplateDirectiveModel {
    @Autowired
    private ISysConfigService iSysConfigService;
    @Override
    public void execute(Environment environment, Map map, TemplateModel[] templateModels, TemplateDirectiveBody templateDirectiveBody) throws TemplateException, IOException {
        DefaultObjectWrapperBuilder builder = new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_25);
        List<SysConfigEntity> sysConfigEntityList = iSysConfigService.selectConfigList(new SysConfigEntity());
        environment.setVariable("listParentBanks1", builder.build().wrap(sysConfigEntityList));
        templateDirectiveBody.render(environment.getOut());
    }
}

